Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Getting "InternalError: too much recursion" when retrieving data from Firebase Realtime DB

I'm putting together a component that is supposed to retrieve all users from the DB, which it does - the problem is that it doesn't stop, and retrieves data from the DB endlessly until the app crashes and unsurprisingly gives the error in the title.

Here is the code in question:

const Dashboard = () => {
      const [usersList, setUsersList] = useState([]);
const userRef = query(ref(db, '/Users'));
onValue(userRef, (snapshot) => {
    let userlist = [];
    snapshot.forEach((snap) => {
        userlist.push(snap.toJSON());
    });
    setUsersList(userlist);
    

}, {
    onlyOnce: true
});
return(
    <div>
    {usersList.map(data => {
        return (
                    <div class="profile_info">
                        {data.name}
                    </div>
        );
    })}
    </div>
)
}

To reiterate, it will provide a list of names as expected, but after a few moments it will crash, providing the "InternalError: too much recursion" error. I've done some troubleshooting on my own prior to posting the question and have narrowed it down to the process of sticking all the data in a temporary array and then setting that array into state being responsible, but everything I've seen online about this process seems to point to that being the proper way to do what I'm trying to do, and so I'm feeling stuck.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!